//create the modal container
var modal_container = tn.createEl('div');
$('body')[0].appendChild(modal_container);

//put the partial in the modal


<%-
    #Rails.logger.debug("Options: #{modal_options.to_json}")
    modal_container_content =
    escape_javascript(
        spurs_modal  modal_file_or_partial,
                     modal_object,
                     modal_options

    )
%>
modal_container.innerHTML = "<%= modal_container_content %>";

if ($(modal_container.children[0]).find('.javascript-hooks').size() > 0) {
    var js_hooks = $(modal_container.children[0]).find('.javascript-hooks');
    var modal = $(modal_container.children[0]);

    modal.on('hidden', function () {
        js_hooks.each(function (idx, item) {
            if ($(item).attr('onhidden')) {
                eval($(item).attr('onhidden'));
            }
        });
    });

    modal.on('hide', function () {
        js_hooks.each(function (idx, item) {
            if ($(item).attr('onhide')) {
                eval($(item).attr('onhide'));
            }
        });
    });

    modal.on('show', function () {
        js_hooks.each(function (idx, item) {
            if ($(item).attr('onShow')) {
                eval($(item).attr('onShow'));
            }
        });
    });

    modal.on('shown', function () {
        js_hooks.each(function (idx, item) {
            if ($(item).attr('onshown')) {
                console.log($(item));
                eval($(item).attr('onshown'));
            }
        });
    });
}

//activate the modal
$(modal_container.children[0]).modal();

if(window._asd != undefined) {
    window._asd();
}